﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using secondhand.L3object;
using secondhand.L2busslogic;
using secondhand.L1database;

namespace secondhand.L4view.yonghu
{
    public partial class yonghu_recharge : System.Web.UI.Page
    { 
        public static userOB yy = new userOB();
        protected void Page_Load(object sender, EventArgs e)
        {
            yy = userBL.Getwordsingle(Session["login"].ToString());
            Label3.Text = yy.user_name;
           
        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {


        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            userOB mydd = new userOB();
            userOB myaa = new userOB();
           
            mydd = userBL.Getwordsingle(Session["login"].ToString());
            myaa = userBL.Getwordsingle(Label3.Text.Trim());
            
            if (TextBox1.Text.Trim().Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('充值的金额不能为空!');</script>");
                return;
            }

            if (TextBox4.Text.Trim().Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('输入的银行账号不能为空!');</script>");
                return;
            }
            if (TextBox2.Text.Trim().Length == 0||TextBox2.Text != mydd.pass_word)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码有误!');</script>");
                return;
            }

            int num = Convert.ToInt32(TextBox1.Text);
            int num1 = Convert.ToInt32(myaa.user_count);
            int total,total1;
            total = num + num1;
            mydd.user_count = total.ToString();
            total1 = Convert.ToInt32(mydd.usable_count) + num;
            mydd.usable_count = total1.ToString();
             if (!userBL.Savemark(mydd)) 
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('充值不成功 ');</script>");
                return;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('充值成功 ');</script>");
                return;
            }
        }
      
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
             userOB mycc= new userOB();
           
            mycc = userBL.Getwordsingle(Label3.Text.Trim());
            TextBox6.Text = mycc.user_count;
        }
        }
    }
